package net.gylka.newsreader;

import java.util.ArrayList;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.GridView;

public class SiteListFragment extends Fragment {

	private ArrayList<NewsSite> mNewsSites;
	private SiteListAdapter mSiteListAdapter;
	
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		// TODO : implement loading list of sites from DB
		
		// Intializing basic list of sites (Pravda.News)
		mNewsSites = new ArrayList<NewsSite>();
		mNewsSites.add(new NewsSite() {{
			mId = NewsSite.ID_PRAVDA_NEWS;
			mName = "Українська правда. Новини";
			mUrl = "www.pravda.com.ua/news/";
		}});
		
		super.onCreate(savedInstanceState);
	}
	
	@Override
	public void onSaveInstanceState(Bundle outState) {
		// TODO Auto-generated method stub
		super.onSaveInstanceState(outState);
	}



	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		View fragmentView = inflater.inflate(R.layout.fragment_site_list, container, false);
		mSiteListAdapter = new SiteListAdapter(this.getActivity(), R.layout.list_site_item, mNewsSites); 
		GridView siteListView = (GridView) fragmentView.findViewById(R.id.gridSiteList);
		siteListView.setAdapter(mSiteListAdapter);
		return fragmentView;
	}
	


}
